﻿@model ItemModel
@using NewLife;
@using NewLife.Cube
@using XCode;
@using XCode.Configuration;
@{
    var name = Model.Name;
	var value = Model.Value;
	var type = Model.Type;
	var length = Model.Length;

	var atts = HtmlHelper.AnonymousObjectToHtmlAttributes(Model.HtmlAttributes);
	if (!atts.ContainsKey("class")) atts.Add("class", "layui-input");
    if (!atts.ContainsKey("placeholder")) atts.Add("placeholder", "请输入内容");
}
@if (name.EqualIgnoreCase("Pass", "Password"))
{
	if (!atts.ContainsKey("autocomplete")) atts.Add("autocomplete", "off");
	@Html.Password(name, value, atts)
}
else if (name.EqualIgnoreCase("Phone", "TelPhone", "OfficePhone", "HomePhone", "Fax"))
{
	if (!atts.ContainsKey("type")) atts.Add("type", "tel");
		@Html.TextBox(name, value, atts)
}
else if (name.EqualIgnoreCase("Mobile", "MobilePhone", "CellularPhone"))
{
	if (!atts.ContainsKey("type")) atts.Add("type", "tel");
		@Html.TextBox(name, value, atts)
}
else if (name.EqualIgnoreCase("email", "mail"))
{
	if (!atts.ContainsKey("type")) atts.Add("type", "email");
		@Html.TextBox(name, value, atts)
}
else if (name.EndsWithIgnoreCase("url"))
{
	//if (!atts.ContainsKey("type")) atts.Add("type", "url");
    @Html.TextBox(name, value, atts)
}
else if (length < 0 || length >= 300 || (length >= 200 && name.EqualIgnoreCase("Remark", "Description", "Comment")))
{
    if (atts.ContainsKey("class")) atts.Remove("class");
    atts.Add("class", "layui-textarea");
	@Html.TextArea(name, (String)value, 3, 20, atts)
}
else
{
	@Html.TextBox(name, value, atts)
}